

from enum import Enum

renewal_from_billing_grace_period_event = {
    # Renewals from Billing Grace Period
    'Promotional Offer from Grace Period with Crossgrade' : 118,
    'Promotional Offer from Grace Period with Upgrade' : 119,
    'Promotional Offer from Grace Period with Downgrade' : 120,
    
    'Introductory Offer from Grace Period with Crossgrade' : 121,
    'Introductory Offer from Grace Period with Upgrade' : 122,
    'Introductory Offer from Grace Period with Downgrade' : 123,
    
    'Crossgrade from Grace Period' : 124,
    'Downgrade from Grace Period' : 125,
    'Upgrade from Grace Period' : 126,
    
    'Offer Code from Grace Period with Downgrade' : 127,
    'Offer Code from Grace Period with Upgrade' : 128,
    'Offer Code from Grace Period with Crossgrade' : 129,
    'Offer Code from Grace Period' : 133,
}

enter_billing_grace_period_events = {
    # Enter Billing Grace Period
    'Grace Period from Paid Subscription' : 113,
    'Grace Period from Introductory Offer' : 114,
    'Grace Period from Promotional Offer' : 115,
    'Grace Period from Opt-In' : 116,
    'Grace Period from Offer Code' : 117,
}

refund_events = {
    # Refunds
    'Refund' : 52,
    'Refund After Renewal Extension' : 53,
}

renewal_events = {
        # Renewals
    'Introductory Offer from Introductory Offer' : 54,
    'Promotional Offer from Opt-In' : 55,
    'Promotional Offer from Opt-In with Upgrade' : 56,
    'Promotional Offer from Opt-In with Downgrade' : 57,
    'Promotional Offer from Opt-In with Crossgrade' : 58,

    'Promotional Offer from Paid Subscription' : 59,
    'Promotional Offer from Paid Subscription with Upgrade' : 60,
    'Promotional Offer from Paid Subscription with Downgrade' : 61,
    'Promotional Offer from Paid Subscription with Crossgrade' : 62,

    'Promotional Offer from Introductory Offer' : 63,
    'Promotional Offer from Introductory Offer with Upgrade' : 64,
    'Promotional Offer from Introductory Offer with Downgrade' : 65,
    'Promotional Offer from Introductory Offer with Crossgrade' : 66,

    'Introductory Offer from Promotional Offer' : 67,
    'Introductory Offer from Promotional Offer with Upgrade' : 68,
    'Introductory Offer from Promotional Offer with Downgrade' : 69,
    'Introductory Offer from Promotional Offer with Crossgrade' : 70,

    'Upgrade' : 71,
    'Downgrade' : 72,
    'Crossgrade' : 73,

    'Opt-in from Promotional Offer' : 74,

    'Introductory Offer from Paid Subscription' : 75,
    'Introductory Offer from Paid Subscription with Upgrade' : 76,
    'Introductory Offer from Paid Subscription with Downgrade' : 77,
    'Introductory Offer from Paid Subscription with Crossgrade' : 78,

    'Opt-in from Introductory Offer' : 79,

    'Introductory Offer from Opt-In' : 80,
    'Introductory Offer Crossgrade from Opt-In' : 81,
    'Introductory Offer Upgrade from Opt-In' : 82,
    'Introductory Offer Downgrade from Opt-In' : 83,

    'Offer Code from Opt-In' : 84,
    'Offer Code from Opt-In with Crossgrade' : 85,
    'Offer Code from Opt-In with Upgrade' : 86,
    'Offer Code from Opt-In with Downgrade' : 87,

    'Offer Code from Introductory Offer' : 88,
    'Offer Code from Introductory Offer with Crossgrade' : 89,
    'Offer Code from Introductory Offer with Upgrade' : 90,
    'Offer Code from Introductory Offer with Downgrade' : 91,

    'Offer Code from Paid Subscription' : 92,
    'Offer Code from Paid Subscription with Crossgrade' : 93,
    'Offer Code from Paid Subscription with Upgrade' : 94,
    'Offer Code from Paid Subscription with Downgrade' : 95,

    'Introductory Offer from Offer Code' : 96,
    'Introductory Offer from Offer Code with Crossgrade' : 97,
    'Introductory Offer from Offer Code with Upgrade' : 98,
    'Introductory Offer from Offer Code with Downgrade' : 99,
    
    'Renewal from Billing Retry' : 100,
    'Crossgrade from Billing Retry' : 101,
    'Downgrade from Billing Retry' : 102,
    'Upgrade from Billing Retry' : 103,
    'Renew' : 104,
    
    'Promotional Offer from Billing Retry' : 105,
    'Promotional Offer from Billing Retry with Upgrade' : 106,
    'Promotional Offer from Billing Retry with Downgrade' : 107,
    'Promotional Offer from Billing Retry with Crossgrade' : 108,
    
    'Offer Code from Billing Retry' : 109,
    'Offer Code from Billing Retry with Upgrade' : 110,
    'Offer Code from Billing Retry with Downgrade' : 111,
    'Offer Code from Billing Retry with Crossgrade' : 112,

    'Introductory Price Downgrade from Billing Retry' : 130,
    'Introductory Price Upgrade from Billing Retry' : 131,
    'Introductory Price Crossgrade from Billing Retry' : 132,
    
}

activation_events = {
    'Subscribe' : 1,
    'Start Introductory Offer' : 2,
    'Opt-In' : 3,
    'Start Offer Code' : 4,
}

cancelation_events = {
    'Cancel' : 5,
    'Canceled from Billing Retry' : 6,
    'Canceled from Billing Grace Period' : 7,
    'Canceled After Renewal Extension' : 8,
}

conversion_to_standard_price_events = {
    # Conversion to Standard Price
    'Paid Subscription from Introductory Offer' : 9,
    'Crossgrade From Introductory Offer' : 10,
    'Downgrade From Introductory Offer' : 11,
    'Upgrade From Introductory Offer' : 12,
    'Paid Subscription From Opt-In' : 13,
    'Crossgrade From Opt-In' : 14,
    'Downgrade From Opt-In' : 15,
    'Upgrade From Opt-In' : 16,
    'Paid Subscription from Introductory Offer' : 17,
    'Crossgrade from Introductory Offer' : 18,
    'Downgrade from Introductory Offer' : 19,
    'Upgrade from Introductory Offer' : 20,
    
    'Paid Subscription from Promonotional Offer' : 21,
    'Paid Subscription from Promonotional Offer with Upgrade' : 22,
    'Paid Subscription from Promonotional Offer with Downgrade' : 23,

    'Paid Subscription from Offer Code' : 24,
    'Paid Subscription from Offer Code with Crossgrade' : 25,
    'Paid Subscription from Offer Code with Upgrade' : 26,
    'Paid Subscription from Offer Code with Downgrade' : 27,
}

event_enter_billing_retry_events = {
        # Entred Billing Retry
    'Billing Retry from Introductory Offer' : 28,
    'Billing Retry from Paid Subscription' : 29,
    'Billing Retry from Grace Period' : 30,
    'Billing Retry from Offer Code' : 31,

    'Billing Retry from Offer Code with Crossgrade' : 32,
    'Billing Retry from Offer Code with Upgrade' : 33,
    'Billing Retry from Offer Code with Downgrade' : 34,
}

_subscription_event_reactivations = {
    
    # Reactivations
    'Reactivate' : 35,
    'Reactivate to Introductory Offer' : 36,
    'Reactivate with Crossgrade' : 37,
    'Reactivate with Upgrade' : 38,
    'Reactivate with Downgrade' : 39,

    'Reactivate with Crossgrade to Introductory Offer' : 40,
    'Reactivate with Upgrade to Introductory Offer' : 41,
    'Reactivate with Downgrade to Introductory Offer' : 42,

    'Reactivation to Promotional Offer' : 43,
    'Reactivation to Promotional Offer with Upgrade' : 44,
    'Reactivation to Promotional Offer with Downgrade' : 45,
    'Reactivation to Promotional Offer with Crossgrade' : 46,

    'Reactivation to Opt-In' : 47,
    'Reactivation to Offer Code' : 48,
    'Reactivation to Offer Code with Upgrade' : 49,
    'Reactivation to Offer Code with Downgrade' : 50,
    'Reactivation to Offer Code with Crossgrade' : 51,

}

subscription_events = {
    **renewal_from_billing_grace_period_event,
    **enter_billing_grace_period_events,
    **refund_events,
    **renewal_events,
    **activation_events,
    **cancelation_events,
    **conversion_to_standard_price_events,
    **event_enter_billing_retry_events,
    **_subscription_event_reactivations
}
    

def isRenewal(event):
    return int(event) in renewal_events.values()

def isRefund(event):
    return int(event) in refund_events.values()

def isActivation(event):
    return int(event) in activation_events.values()


def isCancelation(event):
    return int(event) in cancelation_events.values()

def isConversionToStandardPrice( event):
    return int(event) in conversion_to_standard_price_events.values()

def isEnterBillingRetry( event):
    return int(event) in event_enter_billing_retry_events.values()

def isReactivation(event):
    return int(event) in _subscription_event_reactivations.values()

    
    
    
    

    
    